package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.HashMap;

/**
* @author luo20
* @description 针对表【employee(员工信息)】的数据库操作Mapper
* @createDate 2025-07-04 17:20:05
* @Entity com.sky.entity.Employee
*/
public interface EmployeeMapper extends BaseMapper<Employee> {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);
    /**
     * 插入员工数据
     *
     * @param emp
     */
    @Insert("insert into employee (name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user) " +
            "values " +
            "(#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber},#{status} ,#{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    Integer insertEmp(Employee emp);

    /**
     * 根据id启用、禁用员工账号
     * @param employee
     * @return
     */
    @Update("update employee set status = #{status},update_time = #{updateTime},update_user = #{updateUser} where id = #{id}")
    @AutoFill(value = OperationType.UPDATE)
    Integer updStatus(Employee employee);

    /**
     * 修改密码
     * @param hashMap
     * @return
     */
    @Update("update employee set password = #{newPassword} where id = #{empId}")
    Integer editPassword(HashMap<String, Object> hashMap);
}




